/*
Copyright © 2024 NAME HERE <EMAIL ADDRESS>
*/
package cmd

import (
	"fmt"

	"github.com/spf13/cobra"
)

var configFile string
var outPath string

// replaceCmd represents the replace command
var replaceCmd = &cobra.Command{
	Use:   "replace",
	Short: "替換部署包配置文件",
	Long: `根据config目录，替换openhis 部署包的配置文件：
示例:

	openhis-config.exe replace -f ./variable.yaml -o ./Web"`,
	Run: func(cmd *cobra.Command, args []string) {
		fmt.Println(fmt.Sprintf("使用配置文件 %s，生成院版HIS的配置文件，输出到 %s", configFile, outPath))
		genConfig()
	},
}

func init() {
	rootCmd.AddCommand(replaceCmd)

	// Here you will define your flags and configuration settings.

	// Cobra supports Persistent Flags which will work for this command
	// and all subcommands, e.g.:
	// replaceCmd.PersistentFlags().String("foo", "", "A help for foo")

	// Cobra supports local flags which will only run when this command
	// is called directly, e.g.:
	replaceCmd.Flags().StringP("toggle", "t", "./openhis", "Help message for toggle")
	// 添加 -f 标志，用于指定 YAML 配置文件路径
	replaceCmd.Flags().StringVarP(&configFile, "file", "f", "./variable.yaml", "指定配置文件路径 (默认为 ./variable.yaml)")
	// 添加 -0 标志，用于指定 YAML 配置文件输出路径
	replaceCmd.Flags().StringVarP(&outPath, "outPath", "o", "./Web", "指定配置文件输出路径 (默认为 ./Web)")
}
